package cn.edu.ctbu.firstdp.dao;

import cn.edu.ctbu.firstdp.entity.SC;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;

import java.util.List;
import java.util.Map;

public interface SCRepository extends JpaRepository<SC,Integer> {

//    @Query("SELECT e FROM SC e JOIN FETCH e.student JOIN FETCH e.course")
    @Query(nativeQuery = true,value = "select sc.id,s.name as 学生姓名,s.sno as 学生学号,c.name as 课程名,c.cno as 课程编号 from tb_sc sc" +
            " join tb_student s on s.sno=sc.sno join tb_course c on c.cno=sc.cno")
    List<Map<String,Object>> findAllWithStudentAndCourse();
}
